package service

import (
	"strconv"
	"time"
	"yun_image/dao"
	"yun_image/entity"
	"yun_image/util"
)

// SaveImageShare 生成新的图片分享
func SaveImageShare(imageShare *entity.ImageShare, account string, categoryId int) error {
	imageShare.Id = strconv.FormatInt(time.Now().UnixMilli(), 10) + util.OtherUtil.RandSeq(50)
	imageShare.CreateTime = time.Now().UnixMilli()
	imageShare.IsDeleted = 0
	imageShare.Account = account
	imageShare.CategoryId = categoryId
	err := dao.CreateImageShare(imageShare)
	return err
}

// RemoveImageShare 删除图片分享
func RemoveImageShare(id string, account string) error {
	err := dao.DeleteImageShare(id, account)
	return err
}

// GetImageShareList 根据分类id获取所有图片分享
func GetImageShareList(imageShare *[]entity.ImageShare, categoryId int) error {
	err := dao.GetImageShareList(imageShare, categoryId)
	return err
}
